// 角色管理
import request from '@/utils/request'

// 1、获取角色分页列表  GET /admin/acl/role/{page}/{limit}
export const reqGetPermissionList = (page, limit, roleName) => {
  return request.get(`/admin/acl/role/${page}/${limit}`, { params: { roleName: roleName }})
}

// 2、新增角色  POST /admin/acl/role/save
export const reqAddRole = (role) => {
  return request.post(`/admin/acl/role/save`, role)
}

// 3、删除角色  DELETE /admin/acl/role/remove/{id}
export const reqDelRole = (id) => {
  return request.delete(`/admin/acl/role/remove/${id}`)
}

// 4、删除多个角色  POST /admin/acl/role/batchRemove
export const reqDelRoleAll = (idList) => {
  return request.post(`/admin/acl/role/batchRemove`, idList)
}

// 5、修改角色  PUT /admin/acl/role/update
export const reqUpdataRole = (roleId) => {
  return request.put(`/admin/acl/role/update`, { role: roleId })
}

// 6、获取角色权限列表 /admin/acl/permission/toAssign
export const reqGetRolePermissionList = (roleId) => {
  return request.get(`/admin/acl/permission/toAssign/${roleId}`)
}

// 7、给某个角色授权
export const reqAssignRoleApi = (roleId, permissionId) => {
  return request.post(`/admin/acl/permission/doAssign`, null, {
    params: {
      roleId,
      permissionId
    }
  })
}

